# -*- coding: utf-8 -*-

import os

import imageio

outfilename = r"E:\毕设数据\pictures\avgNDVI\jpg\my.gif"  # 转化的GIF图片名称
filenames = []  # 存储所需要读取的图片名称

# ins_root = r"E:\毕设数据\pictures\avgNDVI"
ins_root = r"E:\毕设数据\pictures\avgNDVI\jpg"
ins = [os.path.join(ins_root, x) for x in os.listdir(ins_root) if x.endswith(".jpg")]

frames = ins


def create_gif(image_list, gif_name):
    frames = []

    for image_name in image_list:
        frames.append(imageio.imread(image_name))

    # Save them as frames into a gif

    imageio.mimsave(gif_name, frames, 'GIF', duration=0.5)

    return


def main():
    image_list = ins

    gif_name = outfilename

    create_gif(image_list, gif_name)


if __name__ == "__main__":
    main()
